package com.yuhq.service.impl;

import com.yuhq.mapper.UserMapper;
import com.yuhq.model.User;
import com.yuhq.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;


//@Scope("prototype")  多例配置
@Service("userService")
public class UserServiceImpl implements UserService {


    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public Integer save(User user) {
        //用户Code不能为空
        // 断言
        Assert.notNull(user.getUserCode(), "用户Code不能为空");
        return userMapper.save(user);
    }
}
